//
//  FollowGroupModel.m
//  剧能玩2.1
//
//  Created by 大兵布莱恩特  on 15/11/11.
//  Copyright © 2015年 大兵布莱恩特 . All rights reserved.
//

#import "FollowGroupModel.h"
#import "PinYinForObjc.h"
#import "FollowModel.h"
@implementation FollowGroupModel


/**
 *
 *
 *  @param dataArray 通讯录姓名
 *  @param title     通讯录名字首字母
 *
 *  @return 这个循环是在另一个循环中，外面的循环已经取出了所有姓名的首字母，用这个循环依次与每个首字母进行比较，最后将首字母相同的姓名添加到对应的首字母数组中，并返回
 */
+ (instancetype)getGroupsWithArray:(NSMutableArray*)dataArray groupTitle:(NSString*)title
{
    NSMutableArray *tempArray = [NSMutableArray array];
    FollowGroupModel *group = [[FollowGroupModel alloc] init];
    for (NSDictionary *dic in dataArray)
    {
        NSString *str = dic[@"RealName"];
        NSString *header = [PinYinForObjc chineseConvertToPinYinHead:str];
        if ([header isEqualToString:title])
        {
            FollowModel *followM = [[FollowModel alloc] init];
            followM.img_Url = @"";
            followM.nickname = str;
//            followM.DepName = dic[@"DepName"];
//            followM.Email = dic[@"Email"];
//            followM.HomeAddress = dic[@"HomeAddress"];
//            followM.Phone = dic[@"Phone"];
//            followM.QQ = dic[@"QQ"];
//            followM.Tel = dic[@"Tel"];
//            followM.UserName = dic[@"UserName"];
//            followM.cName = dic[@"cName"];
            followM.sexName = dic[@"sexName"];
            followM.dic = dic;
            [tempArray addObject:followM];
        }
    }
    group.groupTitle = title;
    group.follows = tempArray;
    return group;
}

/**
 

 @param dataArray 所有联系人数组
 @param title     部门名称

 @return 根据部门 一一对应，将联系人插入数组中
 */
+ (instancetype)getGroupsWithNetData:(NSMutableArray*)dataArray roupTitle:(NSString*)title
{
    NSMutableArray *tempArray = [NSMutableArray array];
    FollowGroupModel *group = [[FollowGroupModel alloc] init];
    for (NSDictionary *dic in dataArray)
    {
//        NSString *header = [PinYinForObjc chineseConvertToPinYinHead:str];
        NSString *depName = dic[@"DepName"];
        if ([depName isEqualToString:title])
        {
            FollowModel *followM = [[FollowModel alloc] init];
            followM.img_Url = @"";
            followM.nickname = dic[@"RealName"];
            followM.dic = dic;
            [tempArray addObject:followM];
        }
    }
    group.groupTitle = title;
    group.follows = tempArray;
    return group;
}
@end
